package io.renren.modules.forYoung.service.impl;


import io.renren.modules.forYoung.dao.NewsDao;
import io.renren.modules.forYoung.entity.NewsEntity;
import io.renren.modules.forYoung.service.NewsService;
import io.renren.modules.oss.entity.MysqlOssEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class NewsServiceImpl  implements NewsService {

    @Autowired
    NewsDao newsDao;

    @Override
    public List<NewsEntity> getMyNewsList(Integer userId) {
        return newsDao.getMyNewsList(userId);
    }

    @Override
    public int delete(Integer id) {
        List<NewsEntity> list=newsDao.getListByParentId(id);
        if(list.size()==0) {
            newsDao.delete(id);
            return 0;
        }
        else
            return 1;
    }
    @Override
    public void upload(Map<String, Object> param) {
        newsDao.insertFile(param);
    }

    @Override
    public MysqlOssEntity getImgByName(String name) {
        return newsDao.getByName(name);
    }

}
